package com.zxy.service;

import com.zxy.dao.ConsumerDAO;
import com.zxy.dao.MusicDAO;
import com.zxy.model.AdminInfo;
import com.zxy.model.ConsumerInfo;
import com.zxy.model.MusicInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class UserServiceImpl implements UserService {
    
    @Resource
    private MusicDAO musicDAO;
    @Resource
    private ConsumerDAO consumerDAO;
    
    @Override
    public boolean checkConsumerInfo(ConsumerInfo consumerInfo) {
        return consumerDAO.checkConsumerInfo(consumerInfo)==1;
    }
    
    @Override
    public boolean checkUserName(String loginName) {
        return consumerDAO.checkUserName(loginName)==1;
    }
    
    @Override
    public boolean insertConsumerInfo(ConsumerInfo consumerInfo) {
        boolean flag;
        if (consumerInfo.getLoginName()==null||consumerInfo.getLoginName().equals("")){
            flag=false;
        }else if (consumerInfo.getPwd()==null||consumerInfo.getPwd().equals("")){
            flag= false;
        }else {
            consumerDAO.insert(consumerInfo);
            flag=true;
        }
        return flag;
    }
    
    @Override
    public List<MusicInfo> getAllMusic() {
        return musicDAO.getAllMusic();
    }
}
